<?php

class HmContact_HmContactController extends Fw_Main
{
	public function sendAction()
	{
		if($this->_request->isPost()) {
			$fwConfig = array(
						  'email'      => 'henrique@krush.com.br',
						  'company'    => 'Krush Internet Inteligente',
						  'smtp_host'  => 'smtp.gmail.com',
						  'smtp_port'  => '465',
						  'smtp_auth'  => 'SSL',
						  'smtp_login' => 'henrique@boombass.com.br',
						  'smtp_pass'  => 'henrique309'
						  );
			Zend_Loader::loadClass('Zend_Mail');
			$formData = $this->_request->getPost('send');
			if($formData) {
				$config = array(
								'port'     => $fwConfig['smtp_port'],
								'ssl'      => $fwConfig['smtp_auth'],
								'auth'     => 'login',
								'username' => $fwConfig['smtp_login'],
								'password' => $fwConfig['smtp_pass']
								);
				$mail = new Zend_Mail();
				$tr = new Zend_Mail_Transport_Smtp($fwConfig['smtp_host'], $config);

				Zend_Mail::setDefaultTransport($tr);
				$message = $this->_request->getPost('from_name').' ('.$this->_request->getPost('from_email').') <br /> '.$this->_request->getPost('message');
				$mail->setBodyText($message)
					->setBodyHtml($message)
					->setFrom($this->_request->getPost('from_email'), $this->_request->getPost('from_name'))
					->addTo($this->_request->getPost('to_email'), $this->_request->getPost('to_name'))
					->setSubject($this->_request->getPost('subject'))
					->send();
				return $this->_helper->redirector('confirm');
			}
		}
	}
	
	public function confirmAction()
	{
		
	}
}